
import Taro from '@tarojs/taro';
import { apiServiceK } from '../../env.config';


export default (options = { method: 'GET', data: {} }) => {

  return Taro.request({
    url: apiServiceK + options.url,
    data: {
      app_id: "jlgnxhfiinvhv8kq",
      app_secret: "ZkQ2UHRnY1lqSldxTEptTW4rQ252UT09",
      ...options.data
    },
    header: options.header || {
      'Content-Type': 'application/json',
    },
    method: options.method.toUpperCase(),

  }).then((res) => {
    const { statusCode, data } = res

    if (statusCode >= 200 && statusCode < 300) {
      return data

    } else {
      throw new Error(`网络请求错误，状态码${statusCode}`)
    }
  }).catch((err) => {
    console.log('请求错误-err', err);
  })
}
